<?php
include '../class/class.pegawai.php';
include '../class/class.golongan.php';
include '../class/class.jabatan.php';

if(isset($_REQUEST['aksi_nip'])){
    $nip=$_REQUEST['nip'];
    $msg=false;
    
    $pegawaiDao=new PegawaiDao();
    
    $pegawai=$pegawaiDao->getPegawai($nip);
    
    if($pegawai!=false){
        $msg=true;
    }
    
    $data=array(
        'msg' => $msg,
        'pegawai' => $pegawai,
    );
    
    echo json_encode($data);
}

if(isset($_REQUEST['aksi_biodata'])){
    
    $pegawaiDao = new PegawaiDao();
    $nip = $_REQUEST['nip'];
    $pegawai = $pegawaiDao->getPegawai($nip);
    $data=array();
    if($pegawai!=false){
        $msg = true;
        $nama = $pegawai['nama'];
        $kdgol = $pegawai['gol'];
        $golDao = new GolonganDao();
        $jabatanDao=new JabatanDao();
        $gol=$golDao->getGolongan($kdgol);
        $nama_gol=$gol['nmgol'];
        $pangkat=$gol['pangkat'];
        
        $data = array(
            'msg' => $msg,
            'nip' => $nip,
            'nama' => $nama,
            'golongan' => $nama_gol,
            'pangkat' => $pangkat,
            'eselon' => $jabatanDao->getJabatan($nip),
        );
    }
    

    echo json_encode($data);
}
?>
